
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; //CupertinoPageRoute ios 风格的跳转
import 'package:wx_chat/pages/AliPay.dart';
import 'package:wx_chat/pages/AppVersion.dart';

import 'package:wx_chat/pages/DataTimeplugin.dart';
import 'package:wx_chat/pages/ImagePick.dart';
import 'package:wx_chat/pages/devices.dart';
import 'package:wx_chat/pages/localstorage.dart';
import 'package:wx_chat/pages/location.dart';
import 'package:wx_chat/pages/network.dart';
import 'package:wx_chat/pages/newDetails.dart';
import 'package:wx_chat/pages/newsList.dart';
import 'package:wx_chat/pages/sacn.dart';
import 'package:wx_chat/pages/urlLaunch.dart';
import 'package:wx_chat/pages/videoplay.dart';


//页面路由
import '../pages/form.dart';
import '../pages/search.dart';
import '../pages/tab.dart';

import '../pages/user/Login.dart';
import '../pages/user/RegisterFirst.dart';
import '../pages/user/RegisterSecond.dart';
import '../pages/user/RegisterThird.dart';
import '../pages/tabbardemo.dart';
import '../pages/tabBarController.dart';
import '../pages/scrollSliver.dart';
import '../pages/tabbardemoFixd.dart';
import '../pages/formtest.dart';
import '../pages/formController.dart';
import '../pages/DataTime.dart';
import 'package:wx_chat/pages/httpPage.dart';


Map routes = {
    '/':(context)=>Tabs(),
    'other':(context)=>FormPage(),
    '/form':(context,{arguments})=>FormPage(arguments:arguments),
    '/search':(context,{arguments})=>Search(arguments:arguments),
    '/login':(context)=>LoginPage(),
    '/registerSencond':(context)=>RegisterSecondPage(),
    '/registerFirst':(context)=>RegisterFirstPage(),
    '/RegisterThird':(context)=>RegisterThirdPage(),
    '/tabbardemo':(context)=>TabBarPage(),
    '/tabBarController':(context)=> TabBarControllerPage(),
    '/CustomScrollView':(context)=> ScroolSlivePage(),
    '/TabbarFixd':(context)=> TabbarFixd(),
    '/formTest':(context)=> FormTest(),
    '/FormTestController':(context)=> FormTestController(),
    '/datatime':(context)=> DataTimePage(),
    '/datatimeplu':(context)=> DataTimePluginPage(),
    '/httpDemo':(context)=>HttpPageDemo(),
    '/newlist':(context)=> NewListPage(),
    '/newdetails':(context,{arguments}) => NewDetailsPage(arguments:arguments),
    '/device':(context)=> DevicesPage(),
    '/location':(context)=> LocationPage(),
    '/imagepick':(context)=> ImagePickePage(),
    '/videoplay':(context)=> VideoPlayPage(),
    '/nexwork':(context)=> NetWorkPage(),
    '/localstorage':(context)=> LocalstoragePage(),
    '/sacn':(context)=> ScanPage(),
    '/version':(context)=> AppVersionPage(),
    '/urllaunch':(context)=> UrlLaunchPage(),
    '/alipay':(context)=> AliPayPage()
};


// ignore: top_level_function_literal_block
var onGenerateRoute = ( RouteSettings settings){
    print(settings);
    // 统一处理
    final String name = settings.name;
    final Function pageContentBuilder = routes[name];
    if (pageContentBuilder != null) {
      if (settings.arguments != null) {
        //有参数  MaterialPageRoute(安卓的  CupertinoPageRoute ios 风格)
        final Route route = CupertinoPageRoute( builder: (context) => pageContentBuilder(context, arguments: settings.arguments));
        return route;
      // ignore: top_level_function_literal_block
      } else {
        // ignore: top_level_function_literal_block
        //无参数
        final Route route = CupertinoPageRoute( builder: (context) => pageContentBuilder(context));
        return route;
      }
    }
};
